#!/usr/bin/env python
import random, os, sys

if __name__ != "__main__":
	sys.exit()

os.system('clear')
banner = """
       ______             _    _               _ 
       | ___ \           | |  | |             | |
   __ _| |_/ /_ _ ___ ___| |  | | ___  _ __ __| |
  / _` |  __/ _` / __/ __| |/\| |/ _ \| '__/ _` |
 | (_| | | | (_| \__ \__ \  /\  / (_) | | | (_| |
  \__, \_|  \__,_|___/___/\/  \/ \___/|_|  \__,_|
     | |                                         
     |_|                                         

    Версия 1.3 BETA
"""
print(banner)

print('\n\n Выберите тип пароля:\n <1> Лёгкий\n <2> Нормальный\n <3> Сложный\n')

pwType = input('>')

os.system('clear')
print(banner)

print('\n\n Этот пароль будет для...:\n <1> Вебсайта\n <2> Программы\n')

pwFor = input('>')

os.system('clear')
print(banner)

print('\n\n Указать длину пароля?: \n <1> Указать\n <2> Оставить рандомным\n')

pwAskL = input('>')

if pwAskL == '1':
	os.system('clear')
	print(banner)

	print('\n\n Введите длину:\n')

	pwL = int(input('>'))

os.system('clear')
print(banner)

print('\n\n ГЕНЕРАЦИЯ ПАРОЛЯ...\n Подождите')

if pwAskL == '1':
	if pwType == '1':
		chars = 'abcdefghijklnopqrstuvwxyz0987654321'
		passw = ''
		for i in range(pwL):
			passw += random.choice(chars)
	elif pwType == '2':
		chars = '_abcdefghijklnopqrstuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ0987654321'
		passw = ''
		for i in range(pwL):
			for z in range(random.randint(2000, 10000)):
				rchar = random.choice(chars)
			passw += random.choice(rchar)
	elif pwType == '3':
		passw = ''
		if pwFor == '1':
			chars = '#!?&$-+=_abcdefghijklnopqrstuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ0987654321'
		elif pwFor == '2':
			chars = '#!?&$-+=<>^/*_abcdefghijklnopqrstuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ0987654321'
		else:
			sys.exit()
		for i in range(pwL):
			r = random.randint(70000,120000)
			for z in range(r):
				rchar = random.choice(chars)
			passw += random.choice(rchar)
	else:
		sys.exit()
else:
	if pwType == '1':
		chars = 'abcdefghijklnopqrstuvwxyz0987654321'
		passw = ''
		for i in range(random.randint(6, 12)):
			passw += random.choice(chars)
	elif pwType == '2':
		chars = '_abcdefghijklnopqrstuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ0987654321'
		passw = ''
		for i in range(random.randint(16, 32)):
			for z in range(random.randint(2000, 10000)):
				rchar = random.choice(chars)
			passw += random.choice(rchar)
	elif pwType == '3':
		passw = ''
		if pwFor == '1':
			chars = '#!?&$-+=_abcdefghijklnopqrstuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ0987654321'
		elif pwFor == '2':
			chars = '#!?&$-+=<>^/*_abcdefghijklnopqrstuvwxyzABCDEFGHIJKLNOPQRSTUVWXYZ0987654321'
		else:
			sys.exit()
		for q in range(random.randint(50000,100000)):
			a = random.randint(86,170)
		for i in range(a):
			r = random.randint(70000,120000)
			for z in range(r):
				rchar = random.choice(chars)
			passw += random.choice(rchar)
	else:
		sys.exit()

os.system('clear')
print(banner)

print('\n\n Ваш пароль был сгенерирован, что вы хотите сделать:\n <1> Показать\n <2> Сохранить\n')

pwAction = input('>')

if pwAction == '1':
	os.system('clear')
	print(banner)
	print('\n\n Вот ваш пароль:\n '+passw)
	input()
	passw = ''
	sys.exit()
elif pwAction == '2':
	os.system('clear')
	print(banner)
	print(' [INFO] Сохранение пароля...')
	pwSave = open('SavedPasswords.txt','a')
	pwSave.write(passw+'\n')
	pwSave.close()
	print(' [SUCCESS] Пароль сохранён')
	input()
	passw = ''
	sys.exit()
else:
	sys.exit()